import { jobPage, jobAdd, jobEdit, jobRemove, jobEnabled, jobDisabled, jobTrigger } from '@/api/system/job'

const state = {}

const mutations = {}

const actions = {
  // jobPage
  jobPage({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      jobPage(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  },
  // jobAdd
  jobAdd({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      jobAdd(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  },
  // jobEdit
  jobEdit({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      jobEdit(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  },
  // jobRemove
  jobRemove({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      jobRemove(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  },
  enabled({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      jobEnabled(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  },
  disabled({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      jobDisabled(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  },
  trigger({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      jobTrigger(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
